package service

import (
	"blog/dao"
	"blog/model"
	"time"
)

var CommonService = &commonService{}

type commonService struct {
}

func (service *commonService) GetBaseInfo() *BaseInfoDTO {
	ipcount, _ := dao.IprecordDao.CountIprecord()
	atccount, _ := dao.ArticleDao.CountArticle(new(model.Article))
	start := time.Date(2019, 6, 1, 0, 0, 0, 0, time.Local)
	now := time.Now()
	return &BaseInfoDTO{ArticleNum: atccount, BrowserNum: ipcount, RunDays: int64(now.Sub(start).Hours() / 24)}
}

type BaseInfoDTO struct {
	ArticleNum int64 `json:"articleNum"`
	BrowserNum int64 `json:"browserNum"`
	RunDays    int64 `json:"runDays"`
}
